package com.cuixichang.minimalism.acl;

import com.cuixichang.minimalism.basal.enums.SubassemblyTypeEnum;
import org.springframework.beans.factory.InitializingBean;

import java.util.*;

public interface PlugDesign extends InitializingBean {
   String plugName();
   String plugDesc();
   // 是否独占
   boolean exclusive();
   // 是否主控(显性还是隐形)
   boolean hidden();
   @Override
   default void afterPropertiesSet(){
      Plug annotation = this.getClass().getAnnotation(Plug.class);
      if(Objects.nonNull(annotation)){
         SubassemblyTypeEnum type = annotation.type();
         Map<SubassemblyTypeEnum, List<PlugDesign>> store = PlugDesignComponent.store;
         List<PlugDesign> orDefault = store.getOrDefault(type, new ArrayList<>());
         orDefault.add(this);
         store.put(type, orDefault);
      }
   }
}
